<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 1.
        var ss = {
            n: 200
        };
        (function (ss) {
            ss.n = 205
            console.log(ss); //{n:205}
            var ss = {
                n: 210
            }
            console.log(ss); //{n:210}
        })(ss)
        console.log(ss); //{n:205}


        // 2.
        var x = 1

        function f(x = 4, y = function () {
            x = 3;
            console.log(x);
        }) {
            console.log(x); //4
            x = 6
            y(); //3
            console.log(x); //3
        }
        f()
        console.log(x); //1


        // 3.
        var obj = {
            n: 100
        }

        function fn(obj, y = function () {
            obj.n = 200;
            console.log(obj.n)
        }) {
            console.log(obj.n) //100
            obj.n = 300
            console.log(obj.n); //300
            var obj = {
                n: 400
            }
            console.log(obj.n); //400
        }
        fn(obj)
        console.log(obj.n); //300

        // 4.
        //属性的赋值优先级比变量高（连等的情况下）
        var a = {n:1};
        var b = a;
        a.x = a = {n:2};
        console.log(a.x);
        console.log(b.x);
    </script>
</body>

</html>